﻿<html>
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="Microsoft.Help.SelfBranded" content="true" />
    <meta name="Language" content="en-us" />
    <meta name="Microsoft.Help.Locale" content="en-us" />
    <meta name="Microsoft.Help.TopicLocale" content="en-us" />
    <link rel="shortcut icon" href="../icons/favicon.ico" />
    <link rel="stylesheet" type="text/css" href="../styles/branding.css" />
    <link rel="stylesheet" type="text/css" href="../styles/branding-en-US.css" />
    <script type="text/javascript" src="../scripts/branding.js"></script>
    <title>CsvHelp.SaveDataTableToCSV Method</title>
    <meta name="Title" content="SaveDataTableToCSV Method" />
    <meta name="Microsoft.Help.Id" content="M:SosoMS.Common.FileHelp.CsvHelp.SaveDataTableToCSV(System.Data.DataTable,System.String,System.String,System.String@,System.Boolean)" />
    <meta name="Microsoft.Help.ContentType" content="Reference" />
    <meta name="System.Keywords" content="CsvHelp.SaveDataTableToCSV method" />
    <meta name="System.Keywords" content="SaveDataTableToCSV method" />
    <meta name="Microsoft.Help.F1" content="SosoMS.Common.FileHelp.CsvHelp.SaveDataTableToCSV" />
    <meta name="Microsoft.Help.F1" content="CsvHelp.SaveDataTableToCSV" />
    <meta name="Microsoft.Help.F1" content="SaveDataTableToCSV" />
    <meta name="container" content="SosoMS.Common.FileHelp" />
    <meta name="file" content="f97adc46-9fe2-5968-bc4c-064a502aa694" />
    <meta name="guid" content="f97adc46-9fe2-5968-bc4c-064a502aa694" />
    <meta name="Description" content="将中的数据保存到CSV文件中" />
    <link rel="stylesheet" type="text/css" href="../styles/branding-Help1.css" />
  </head>
  <body onload="SetDefaultLanguage('cs');">
    <input type="hidden" id="userDataCache" class="userDataStyle" />
    <div id="PageHeader" class="pageHeader">嗖嗖常用方法帮助集</div>
    <div class="pageBody">
      <div id="TopicContent" class="topicContent">
        <table class="titleTable">
          <tr>
            <td class="titleColumn">
              <h1>Csv<wbr />Help<span id="LST9D9C00_0" data-languageSpecificText="cpp=::|nu=."></span>Save<wbr />Data<wbr />Table<wbr />To<wbr />CSV Method</h1>
            </td>
          </tr>
        </table>
        <div class="summary">
            将<a href="https://learn.microsoft.com/dotnet/api/system.data.datatable" target="_blank" rel="noopener noreferrer">DataTable</a>中的数据保存到CSV文件中
            </div>
        <br />
        <strong>Namespace:</strong> <a href="4f2fecb0-966c-232d-a819-c35018f8ad72.htm">SosoMS.Common.FileHelp</a><br /><strong>Assembly:</strong> SosoMS.Common (in SosoMS.Common.dll) Version: 1.0.0<div class="collapsibleAreaRegion"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('IDB')" onkeypress="SectionExpandCollapse_CheckKey('IDB', event)" tabindex="0"><img id="IDBToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />Syntax</span></div><div id="IDBSection" class="collapsibleSection"><div id="IDAB" class="codeSnippetContainer"><div class="codeSnippetContainerTabs"><div id="IDAB_tab1" class="codeSnippetContainerTab"><a href="#" onclick="ChangeTab('IDAB','cs','1','4');return false;">C#</a></div><div id="IDAB_tab2" class="codeSnippetContainerTab"><a href="#" onclick="ChangeTab('IDAB','vb','2','4');return false;">VB</a></div><div id="IDAB_tab3" class="codeSnippetContainerTab"><a href="#" onclick="ChangeTab('IDAB','cpp','3','4');return false;">C++</a></div><div id="IDAB_tab4" class="codeSnippetContainerTab"><a href="#" onclick="ChangeTab('IDAB','fs','4','4');return false;">F#</a></div></div><div class="codeSnippetContainerCodeContainer"><div class="codeSnippetToolBar"><div class="codeSnippetToolBarText"><a id="IDAB_copyCode" href="#" class="copyCodeSnippet" onclick="CopyToClipboard('IDAB');return false;" title="Copy">Copy</a></div></div><div id="IDAB_code_Div1" class="codeSnippetContainerCode" style="display: block"><pre xml:space="preserve"><span class="keyword">public</span> <span class="keyword">static</span> <span class="identifier">bool</span> <span class="identifier">SaveDataTableToCSV</span>(
	<span class="identifier">DataTable</span> <span class="parameter">dt</span>,
	<span class="identifier">string</span> <span class="parameter">path</span>,
	<span class="identifier">string</span> <span class="parameter">fileName</span>,
	<span class="keyword">out</span> <span class="identifier">string</span> <span class="parameter">errorInfo</span>,
	<span class="identifier">bool</span> <span class="parameter">isOverlay</span> = <span class="keyword">false</span>
)</pre></div><div id="IDAB_code_Div2" class="codeSnippetContainerCode" style="display: none"><pre xml:space="preserve"><span class="keyword">Public</span> <span class="keyword">Shared</span> <span class="keyword">Function</span> <span class="identifier">SaveDataTableToCSV</span> ( 
	<span class="parameter">dt</span> <span class="keyword">As</span> <span class="identifier">DataTable</span>,
	<span class="parameter">path</span> <span class="keyword">As</span> <span class="identifier">String</span>,
	<span class="parameter">fileName</span> <span class="keyword">As</span> <span class="identifier">String</span>,
	&lt;<span class="identifier">OutAttribute</span>&gt; <span class="keyword">ByRef</span> <span class="parameter">errorInfo</span> <span class="keyword">As</span> <span class="identifier">String</span>,
	Optional <span class="parameter">isOverlay</span> <span class="keyword">As</span> <span class="identifier">Boolean</span> = <span class="keyword">false</span>
) <span class="keyword">As</span> <span class="identifier">Boolean</span></pre></div><div id="IDAB_code_Div3" class="codeSnippetContainerCode" style="display: none"><pre xml:space="preserve"><span class="keyword">public</span>:
<span class="keyword">static</span> <span class="identifier">bool</span> <span class="identifier">SaveDataTableToCSV</span>(
	<span class="identifier">DataTable</span>^ <span class="parameter">dt</span>, 
	<span class="identifier">String</span>^ <span class="parameter">path</span>, 
	<span class="identifier">String</span>^ <span class="parameter">fileName</span>, 
	[<span class="identifier">OutAttribute</span>] <span class="identifier">String</span>^% <span class="parameter">errorInfo</span>, 
	<span class="identifier">bool</span> <span class="parameter">isOverlay</span> = <span class="keyword">false</span>
)</pre></div><div id="IDAB_code_Div4" class="codeSnippetContainerCode" style="display: none"><pre xml:space="preserve"><span class="keyword">static</span> <span class="keyword">member</span> <span class="identifier">SaveDataTableToCSV</span> : 
        <span class="parameter">dt</span> : <span class="identifier">DataTable</span> * 
        <span class="parameter">path</span> : <span class="identifier">string</span> * 
        <span class="parameter">fileName</span> : <span class="identifier">string</span> * 
        <span class="parameter">errorInfo</span> : <span class="identifier">string</span> <span class="keyword">byref</span> * 
        ?<span class="parameter">isOverlay</span> : <span class="identifier">bool</span> 
(* Defaults:
        <span class="keyword">let </span><span class="identifier">_</span><span class="identifier">isOverlay</span> = defaultArg <span class="identifier">isOverlay</span> <span class="keyword">false</span>
*)
<span class="keyword">-&gt;</span> <span class="identifier">bool</span> </pre></div></div></div><h4>Parameters</h4><dl><dt class="has-text-weight-normal"><span class="parameter">dt</span>  <a href="https://learn.microsoft.com/dotnet/api/system.data.datatable" target="_blank" rel="noopener noreferrer">DataTable</a></dt><dd>数据源</dd><dt class="has-text-weight-normal"><span class="parameter">path</span>  <a href="https://learn.microsoft.com/dotnet/api/system.string" target="_blank" rel="noopener noreferrer">String</a></dt><dd>保存路径</dd><dt class="has-text-weight-normal"><span class="parameter">fileName</span>  <a href="https://learn.microsoft.com/dotnet/api/system.string" target="_blank" rel="noopener noreferrer">String</a></dt><dd>保存文件名</dd><dt class="has-text-weight-normal"><span class="parameter">errorInfo</span>  <a href="https://learn.microsoft.com/dotnet/api/system.string" target="_blank" rel="noopener noreferrer">String</a><span id="LST9D9C00_1" data-languageSpecificText="cpp=%"></span></dt><dd>错误信息</dd><dt class="has-text-weight-normal"><span class="parameter">isOverlay</span>  <a href="https://learn.microsoft.com/dotnet/api/system.boolean" target="_blank" rel="noopener noreferrer">Boolean</a>  (Optional)</dt><dd>是否覆盖存在文件</dd></dl><h4>Return Value</h4><a href="https://learn.microsoft.com/dotnet/api/system.boolean" target="_blank" rel="noopener noreferrer">Boolean</a><br />是否成功，成功返回<span class="keyword"><span id="LST9D9C00_2" data-languageSpecificText="vb=True|nu=true"></span></span>, 失败返回<span class="keyword"><span id="LST9D9C00_3" data-languageSpecificText="vb=False|nu=false"></span></span></div><div class="collapsibleAreaRegion"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('IDBC')" onkeypress="SectionExpandCollapse_CheckKey('IDBC', event)" tabindex="0"><img id="IDBCToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />Remarks</span></div><div id="IDBCSection" class="collapsibleSection">
            将<a href="https://learn.microsoft.com/dotnet/api/system.data.datatable" target="_blank" rel="noopener noreferrer">DataTable</a>中的数据保存到CSV文件中，<a href="https://learn.microsoft.com/dotnet/api/system.data.datatable" target="_blank" rel="noopener noreferrer">DataTable</a>中的<a href="https://learn.microsoft.com/dotnet/api/system.data.datatable.columns#system-data-datatable-columns" target="_blank" rel="noopener noreferrer">Columns</a>作为文件的表头<br /><a href="https://learn.microsoft.com/dotnet/api/system.data.datatable" target="_blank" rel="noopener noreferrer">DataTable</a>中的<a href="https://learn.microsoft.com/dotnet/api/system.data.datatable.rows#system-data-datatable-rows" target="_blank" rel="noopener noreferrer">Rows</a>作为文件的内容
            </div><div class="collapsibleAreaRegion"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('seeAlso')" onkeypress="SectionExpandCollapse_CheckKey('seeAlso', event)" tabindex="0"><img id="seeAlsoToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />See Also</span></div><div id="seeAlsoSection" class="collapsibleSection"><h4>Reference</h4><div><a href="096ac194-66bf-6a4a-23f1-c6742e68b116.htm">CsvHelp Class</a></div><div><a href="4f2fecb0-966c-232d-a819-c35018f8ad72.htm">SosoMS.Common.FileHelp Namespace</a></div></div></div>
    </div>
    <div id="PageFooter" class="pageFooter" />
  </body>
</html>